
#delimit;
clear all;
version 13.1;
pause on;
program drop _all;
capture log close;
set more off;

/*INSERT FOLDER PATH*/
cd /;



/*entry*/

use pmra_level_freq.dta, clear;

xtqmlp nb_pmra treat i.year, fe i(id) cluster(case_code) ;
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct id if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_pmra.ster, replace;
xtqmlp nb_pmra_pct20 treat i.year, fe i(id) cluster(case_code) ;
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct id if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_pmra_pct20.ster, replace;
xtqmlp nb_pmra_rnk10 treat i.year, fe i(id) cluster(case_code) ;
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct id if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_pmra_rnk10.ster, replace;

xtqmlp nb_pmra_hijif treat i.year, fe i(id) cluster(case_code) ;
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct id if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_pmra_hijif.ster, replace;

xtqmlp nb_pmra_lojif treat i.year, fe i(id) cluster(case_code) ;
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct id if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_pmra_lojif.ster, replace;


/*funding*/


use pmra_level_funding.dta, clear;

replace amount=amount/1000000;

xtqmlp nbgrants treat i.year, fe i(id) cluster(case_code) ;
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct id if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_nbgrants.ster, replace;
xtqmlp amount treat i.year, fe i(id) cluster(case_code) ;
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct id if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_amount.ster, replace;


/*table*/


set emptycells drop;
set matsize 1000;
estimates drop _all;

estimates use  estimates/poisson_pmra.ster;
eststo;
estimates use  estimates/poisson_pmra_pct20.ster;
eststo;
estimates use  estimates/poisson_pmra_rnk10.ster;
eststo;
estimates use  estimates/poisson_pmra_hijif.ster;
eststo;
estimates use  estimates/poisson_pmra_lojif.ster;
eststo;
estimates use  estimates/poisson_nbgrants.ster;
eststo;
estimates use  estimates/poisson_amount.ster;
eststo;

esttab *, keep(treat) varwidth(25) nonumber noobs nogaps nodep label b(%5.3f) se(%5.3f) star(� 0.10 * 0.05 ** 0.01) compress scalars("nbcases Nb. of Retraction Cases" "N_g Nb. of Treating/Control Articles" "N Nb. of Article-Year Obs." "ll Log Likelihood") sfmt(%10.0fc %10.0fc %10.0fc %10.0fc) mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)") eqlabels(none);
esttab * using tables/table_poisson_entry&funding.rtf, keep(treat) varwidth(25) nonumber noobs nogaps nodep label b(%5.3f) se(%5.3f) star(� 0.10 * 0.05 ** 0.01) compress scalars("nbcases Nb. of Retraction Cases" "N_g Nb. of Treating/Control Articles" "N Nb. of Article-Year Obs." "ll Log Likelihood") sfmt(%10.0fc %10.0fc %10.0fc %10.0fc) mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)") eqlabels(none) replace;
